Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
endian.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/target_posix/roc_core/endian.h
10//! @brief Endian converters.
11
12#ifndef ROC_CORE_ENDIAN_H_
13#define ROC_CORE_ENDIAN_H_
14
15#include <arpa/inet.h>
16#include <inttypes.h>
17#include <netinet/in.h>
18#include <sys/types.h>
19
20namespace roc {
21namespace core {
22
23//! Network to host (16 bits).
24inline uint16_t ntoh16(uint16_t v) {
25 return ntohs(v);
26}
27
28//! Network to host (32 bits).
29inline uint32_t ntoh32(uint32_t v) {
30 return ntohl(v);
31}
32
33//! Host to network (16 bits).
34inline uint16_t hton16(uint16_t v) {
35 return htons(v);
36}
37
38//! Host to network (32 bits).
39inline uint32_t hton32(uint32_t v) {
40 return htonl(v);
41}
42
43} // namespace core
44} // namespace roc
45
46#endif // ROC_CORE_ENDIAN_H_
uint16_t hton16(uint16_t v)
Host to network (16 bits).
Definition: endian.h:34
uint32_t ntoh32(uint32_t v)
Network to host (32 bits).
Definition: endian.h:29
uint16_t ntoh16(uint16_t v)
Network to host (16 bits).
Definition: endian.h:24
uint32_t hton32(uint32_t v)
Host to network (32 bits).
Definition: endian.h:39
Root namespace.